let app = getApp();
import {
  imageUrl
} from "../../utils/imageutil"
Component({
  options: {
    addGlobalClass: true,
    styleIsolation: "apply-shared"
  },
  properties: {
    selected: {
      type: Number,
      value: 0
    },
    num: {
      type: Number,
      value: 0
    },
  },
  data: {
    "color": "#666666",
    "selectedColor": "#ee6e01",
    "backgroundColor": "#ffffff",
    "list": [{
      "pagePath": "/aunt/pages/index/index",
      "text": "首页",
      "id": 5,
      "iconPath": imageUrl + "/tabbarIcon/index.png",
      "selectedIconPath": imageUrl + "/tabbarIcon/indexs.png"
    }, {
      "pagePath": "/aunt/pages/index/order",
      "text": "订单",
      "id": 6,
      "iconPath": imageUrl + "/tabbarIcon/order.png",
      "selectedIconPath": imageUrl + "/tabbarIcon/orderSelected.png"
    }, {
      "pagePath": "/pages/news/news?type=is_aunt",
      "text": "消息",
      "id": 7,
      "iconPath": imageUrl + "/tabbarIcon/news.png",
      "selectedIconPath": imageUrl + "/tabbarIcon/newss.png"
    }, {
      "pagePath": "/aunt/pages/index/my",
      "text": "我的",
      "id": 8,
      "iconPath": imageUrl + "/tabbarIcon/my.png",
      "selectedIconPath": imageUrl + "/tabbarIcon/mys.png"
    }]
  },
  attached() {

  },
  lifetimes: {
    attached: function () {
      // 在组件实例进入页面节点树时执行
    },
    ready: function () {
      // 组件布局完成，这时可以获取节点信息，也可以操作节点
      this.setData({
        num: getApp().globalData.unreadCount
      })
    },
  },
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      if (this.data.selected != data.id) {
        wx.redirectTo({
          url
        })
      }
    },
  }
})